package robot;

import logging.Logger;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.sql.*;

/**
 * Data class for storing session data.
 * @author BDS
 */
public class SessionResult
{
	private int id;
	private String environmentName;
	private String machine;
	private String version;
	private Timestamp startTime;
	private Timestamp endTime;
	private boolean success;

	/**
	 * Class constructor.
	 */
	public SessionResult()
	{
		id = -1;
		environmentName = "New environment";
		try
		{
			machine = InetAddress.getLocalHost().getHostName();
		}
		catch (UnknownHostException exception)
		{
			Logger.logException(exception);
		}
		version = "0.0.0000.0";
		startTime = new Timestamp(System.currentTimeMillis());
		endTime = new Timestamp(System.currentTimeMillis());
		success = true;
	}
	
	/**
	 * Getter for the ID, the IDENTITY value from the remote database.
	 * @return The ID.
	 */
	public int getID() { return id; }
	
	/**
	 * Setter for the ID, the IDENTITY value from the remote database.
	 * @param id The ID.
	 */
	public void setID(int id) { this.id = id; }
	
	/**
	 * Getter for the Environment name.
	 * @return The Environment name.
	 */
	public String getEnvironmentName() { return environmentName; }
	
	/**
	 * Setter for the Environment name.
	 * @param environmentName The Environment name.
	 */
	public void setEnvironmentName(String environmentName) { this.environmentName = environmentName; }

	/**
	 * Getter for the machine.
	 * @return The machine.
	 */
	public String getMachine() { return machine; }
	
	/**
	 * Setter for the machine.
	 * @param machine The machine.
	 */
	public void setMachine(String machine) { this.machine = machine; }
	
	/**
	 * Getter for the version.
	 * @return The version.
	 */
	public String getVersion() { return version; }
	
	/**
	 * Setter for the version.
	 * @param version The version.
	 */
	public void setVersion(String version) { this.version = version; }
	
	/**
	 * Getter for the start time.
	 * @return The start time.
	 */
	public Timestamp getStartTime() { return startTime; }
	
	/**
	 * Setter for the start time.
	 * @param startTime The start time.
	 */
	public void setStartTime(Timestamp startTime) { this.startTime = startTime; }
	
	/**
	 * Getter for the end time.
	 * @return The end time.
	 */
	public Timestamp getEndTime() { return endTime; }
	
	/**
	 * Setter for the end time.
	 * @param endTime The end time.
	 */
	public void setEndTime(Timestamp endTime) { this.endTime = endTime; }
	
	/**
	 * Getter for the success flag.
	 * @return The success flag.
	 */
	public boolean getSuccess() { return success; }
	
	/**
	 * Setter for the success flag.
	 * @param success The success flag.
	 */
	public void setSuccess(boolean success) { this.success = success; }
}
